// 菜单管理相关接口
import request from "@/utils/request"
import type { AllPermissionResponseData, MenuParams } from './type'
// 枚举地址
enum API {
   // 获取菜单相关数据
   ALLPERMISSION_URL = '/admin/acl/permission',
   // 新增子菜单
   ADDMENU_URL = '/admin/acl/permission/save',
   // 更新菜单
   UPDATEMENU_URL = '/admin/acl/permission/update',
   // 删除已有的菜单
   DELETEMENU_URL = '/admin/acl/permission/remove/'
}
// 获取菜单数据的方法
export const reqAllPermission = () => request.get<any, AllPermissionResponseData>(API.ALLPERMISSION_URL)
// 添加与更新菜单的方法
export const reqAddOrUpdateMenu = (data: MenuParams) => {
   if (data.id) {
      return request.put<any, any>(API.UPDATEMENU_URL, data)
   } else {
      return request.post<any, any>(API.ADDMENU_URL, data)
   }
}
// 删除已有菜单的方法
export const reqDeleteMenu = (id: number) => request.delete<any, any>(API.DELETEMENU_URL + id)